package com.iot.auth.endpoint;

import com.iot.common.core.util.R;
import com.iot.common.core.util.WebUtils;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class SecurityAuthenticationEntryPoint implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
		WebUtils.renderJson(response, R.failed(HttpServletResponse.SC_FORBIDDEN,"访问资源受限！",authException.getMessage()));
    }
}
